package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName: WmMaterialController
 * Description:
 * date: 2023/8/8 0008 17:09
 *
 * @author zHan
 */

@RestController
@Slf4j
@RequestMapping("/api/v1/material")
@Api(tags = "自媒体素材相关接口")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 图片上传
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    @ApiOperation("图片上传")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 图片列表
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("图片列表")
    public ResponseResult list(@RequestBody WmMaterialDto wmMaterialDto) {
        return wmMaterialService.getMaterialList(wmMaterialDto);
    }

    /**
     * 图片删除
     * @param id
     * @return
     */
    @GetMapping("/del_picture/{id}")
    @ApiOperation("图片删除")
    public ResponseResult deletePicture(@PathVariable Integer id) {
        return wmMaterialService.deletePicture(id);
    }

    /**
     * 图片收藏
     * @param id
     * @return
     */
    @GetMapping("/collect/{id}")
    @ApiOperation("图片收藏")
    public ResponseResult collectPicture(@PathVariable Integer id) {
        return wmMaterialService.collectPicture(id);
    }

    /**
     * 取消收藏
     * @param id
     * @return
     */
    @GetMapping("/cancel_collect/{id}")
    @ApiOperation("取消收藏")
    public ResponseResult cancelCollect(@PathVariable Integer id) {
        return wmMaterialService.cancelCollect(id);
    }

}
